package com.study.spaoplog.service;

/**
 * @author MI
 * @version 1.0
 * @date 2021/6/4 21:45
 */

import com.study.spaoplog.anno.NeedLock;
import com.study.spaoplog.bean.SysLog;
import com.study.spaoplog.constant.SysConst;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class HelloService {
    public String dateStr() {
        log.info("HelloService.dateStr");
        return new DateTime().toString();
    }

    @NeedLock(key = SysConst.STR_LOCK)
    public String randStr(String strLock) {
        return RandomStringUtils.randomAlphabetic(5) + SysConst.STR_LOCK;
    }

    @NeedLock(key = "#args[0]")
    public String randStr(String strLock, LocalDateTime dateTime) {
        return RandomStringUtils.randomAlphabetic(5);
    }

    @NeedLock(key = "#args[0].getUid")
    public String randStr(SysLog sysLog) {
        System.out.println(sysLog.toString());
        return RandomStringUtils.randomAlphabetic(5);
    }
}
